    //
//  MenuController.m
//  Quiz
//
//  Created by AnhLH-Oriolus on 28/07/2011.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "MenuController.h"
#import "countryquizAppDelegate.h"
#import "MainController.h"
#import "FontLabel.h"

@implementation MenuController

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-(id)init{
	self = [super init];
	
	return self;
}

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
	[v setBackgroundColor:[UIColor clearColor]];
	[v setUserInteractionEnabled:YES];
	self.view = v;
	[v release];
///////////

	FontLabel *lbl = [[FontLabel alloc] initWithFrame:CGRectMake(10, 200, 300, 40) fontName:@"scoreboard" pointSize:30];
	[lbl setBackgroundColor:[UIColor blackColor]];
	lbl.textAlignment = UITextAlignmentCenter;
	lbl.textColor = [UIColor colorWithRed:243 green:255 blue:62 alpha:1.0];
	lbl.text = @"Play";
	[self.view addSubview:lbl];
	[lbl release];
	
	UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(110, 200, 100, 40)];
	[btn setBackgroundColor:[UIColor clearColor]];
	[btn addTarget:nil action:@selector(openPlayerViewController) forControlEvents:UIControlEventTouchUpInside];
	[self.view addSubview:btn];
	[btn release];
//////////////	
	FontLabel *lbl1 = [[FontLabel alloc] initWithFrame:CGRectMake(10, 280, 300, 40) fontName:@"scoreboard" pointSize:30];
	[lbl1 setBackgroundColor:[UIColor blackColor]];
	lbl1.textAlignment = UITextAlignmentCenter;
	lbl1.textColor = [UIColor colorWithRed:243 green:255 blue:62 alpha:1.0];
	lbl1.text = @"Score";
	[self.view addSubview:lbl1];
	[lbl1 release];
	
	UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(110, 280, 100, 40)];
	[btn1 setBackgroundColor:[UIColor clearColor]];
	[btn1 addTarget:self action:@selector(openScoreController:) forControlEvents:UIControlEventTouchUpInside];
	[self.view addSubview:btn1];
	[btn1 release];
////////////////	
	FontLabel *lbl2 = [[FontLabel alloc] initWithFrame:CGRectMake(10, 360, 300, 40) fontName:@"scoreboard" pointSize:30];
	[lbl2 setBackgroundColor:[UIColor blackColor]];
	lbl2.textAlignment = UITextAlignmentCenter;
	lbl2.textColor = [UIColor colorWithRed:243 green:255 blue:62 alpha:1.0];
	lbl2.text = @"About";
	[self.view addSubview:lbl2];
	[lbl2 release];
	
	UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(110, 360, 100, 40)];
	[btn2 setBackgroundColor:[UIColor clearColor]];
	[btn2 addTarget:nil action:@selector(openAboutView) forControlEvents:UIControlEventTouchUpInside];
	[self.view addSubview:btn2];
	[btn2 release];
}

-(void)openPlayerViewController{
	[g_AppDelegate.mainCtrl openPlayerController];
}

-(void)openScoreController:(id)sender{
	NSLog(@"%@ - %d", g_AppDelegate.sName, g_AppDelegate.iScore);
	[g_AppDelegate.mainCtrl goToScoreWithMode:0 ofPlayerName:g_AppDelegate.sName andScore:g_AppDelegate.iScore];
}

-(void)openAboutView{
	NSLog(@"help");
	
	[g_AppDelegate.mainCtrl openAboutView];
}

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
